package com.csk.zsk.compents.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.csk.zsk.commons.orm.PropertyFilter.MatchType;
import com.csk.zsk.compents.dao.ComicChaptersDao;
import com.csk.zsk.compents.dao.ComicDao;
import com.csk.zsk.compents.dao.ComicPagesDao;
import com.csk.zsk.compents.entity.Comic;
import com.csk.zsk.compents.entity.ComicChapters;
import com.csk.zsk.compents.entity.ComicPages;
import com.csk.zsk.compents.service.ComicService;

@Service
@Transactional
public class ComicServiceImpl implements ComicService {
	@Autowired
	private ComicDao comicDao;
	@Autowired
	private ComicChaptersDao comicChaptersDao;
	@Autowired
	private ComicPagesDao comicPagesDao;
	
	@Override
	@Transactional(readOnly = true)
	public Comic searchComicById(String id) {
		
		return  comicDao.getIdByGetMethod(id);
		
	}

	@Override
	@Transactional(readOnly = true)
	public List<Comic> searchComicByAuthor(String author) {
		return comicDao.findBy("author", author);
		
	}

	@Override
	@Transactional(readOnly = true)
	public List<Comic> searchComicByLikeName(String likename) {
		return comicDao.findBy("name", likename, MatchType.LIKE);	
	}

	@Override
	@Transactional(readOnly = true)
	public ComicChapters searchComicChaptersById(String id) {
		
		return comicChaptersDao.get(id);
		
	}

	@Override
	@Transactional(readOnly = true)
	public ComicPages searchComicPagesById(String id) {
		
		return comicPagesDao.get(id);
	}

	@Override
	@Transactional(readOnly = true)
	public List<Comic> searchTop10ByOrder(String startIndex) {
		return comicDao.searchTop10ByOrder(startIndex);
		
	}

	@Override
	@Transactional(readOnly = true)
	public List<Comic> searchTop10ByRec(String startIndex) {
		return comicDao.searchTop10ByRec(startIndex);
	}

	@Override
	@Transactional(readOnly = true)
	public List<Comic> searchTop10ByRandom() {
		return comicDao.searchTop10ByRandom();
	}

	

}
